/**
 * Created by ydz on 15/11/11.
 */
$(document).ready(function(){
    var username = getCookie("username");
    $("#username").text(username);
    var uid = getCookie("uid");
    if(username==null||uid==null){
        layer.confirm('您未登录系统，请登录系统。', {
            btn: ['确定'], //按钮
            shade: 1
        }, function(){
            window.open("login.html","_self");
        });
    }else{
        getBoxChartsData();//箱线图
        //getTimeChartsData();//标准散点图
        //getPieChartsGrammarData();//封闭环状图语法
        //getPieChartsListeningData();
        //getPieChartsReadingData();
        //getPieChartsLineData();
        //getliData();
        getKeyData();
    }
});
$("#logout").click(function(){
    layer.confirm('您确定要退出系统吗？', {
        btn: ['取消','确定'], //按钮
        shade: 0.8
    },function(index){
        layer.close(index);
    }, function(){
        delCookie("username");
        delCookie("uid");
        delCookie("rid");
        window.open("login.html","_self");
    });
});
//写cookies
function setCookie(c_name, value, expiredays){
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie=c_name+ "=" + escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

//读取cookies
function getCookie(name)
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");

    if(arr=document.cookie.match(reg))

        return (arr[2]);
    else
        return null;
}

//删除cookies
function delCookie(name)
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null)
        document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
$("#result").click(function(){
    window.open("answerindex.html","_self")
});
function getBoxChartsData() {
    //通过Ajax获取数据
    $.ajax({
        type : "post",
        //async : false, //同步执行
        url : "http://vip.classba.com/crm/index.php?m=evaluate&a=getAllData",
        data : {
            "rid":getCookie("rid"),
            "exam_id":1
        },
        dataType : "json", //返回数据形式为json
        success : function(result) {
            var total = [],listening = [],reading = [],grammar = [],myscore = [];
            console.log(JSON.stringify(result));
            if (result) {
                $('#userscore').text(result.examResult.myscore);
                $('#listening-num').text(result.examResult.listening[0]);
                $('#listening-right').text(result.examResult.listening[1]);
                $('#listening-score').text(result.examResult.listening[2]);
                $('#listening-uscore').text(result.examResult.listening[3]);
                $('#reading-num').text(result.examResult.reading[0]);
                $('#reading-right').text(result.examResult.reading[1]);
                $('#reading-score').text(result.examResult.reading[2]);
                $('#reading-uscore').text(result.examResult.reading[3]);
                $('#grammar-num').text(result.examResult.grammar[0]);
                $('#grammar-right').text(result.examResult.grammar[1]);
                $('#grammar-score').text(result.examResult.grammar[2]);
                $('#grammar-uscore').text(result.examResult.grammar[3]);
                for(var i = 0;i<result.boxchart.total.length;i++){
                    total.push(parseInt(result.boxchart.total[i]));
                    listening.push(parseInt(result.boxchart.listening[i]));
                    reading.push(parseInt(result.boxchart.reading[i]));
                    grammar.push(parseInt(result.boxchart.grammar[i]));
                }
                for(var i = 0;i<result.boxchart.myscore.length;i++){
                    myscore.push(parseInt(result.boxchart.myscore[i]));
                    //console.log(JSON.stringify(myscore));
                }
                //console.log(JSON.stringify(myscore));
                $('#main-boxlinechart').highcharts({

                    chart: {
                        type: 'boxplot'
                    },
                    credits: {
                        enabled:false
                    },
                    //colors:[
                    //    '#4B86D6', '#4FB3E0', '#51C3C9', '#4FE0BE', '#4BD68F',
                    //    '#4B86D6', '#4FB3E0', '#51C3C9', '#4FE0BE', '#4BD68F',
                    //    '#4B86D6', '#4FB3E0', '#51C3C9', '#4FE0BE', '#4BD68F',
                    //    '#4B86D6', '#4FB3E0', '#51C3C9', '#4FE0BE', '#4BD68F'
                    //],
                    title: {
                        text: null
                    },

                    legend: {
                        enabled: false
                    },
                    xAxis: {
                        categories: result.boxchart.xAxis,
                        title: {
                            text: null
                        }
                    },
                    color:'#4FB3E0',
                    yAxis: {
                        title: {
                            text: null
                        }
                    },

                    series: [{
                        name: '得分情况',
                        data: [
                            total.sort(function(a,b){return a>b?1:-1}),
                            listening.sort(function(a,b){return a>b?1:-1}),
                            grammar.sort(function(a,b){return a>b?1:-1}),
                            reading.sort(function(a,b){return a>b?1:-1})
                        ],
                        tooltip: {
                            headerFormat: '<em> {point.key}</em>'
                        }
                    }, {
                        name: '我的得分',
                        color:'#4FE0BE',
                        type: 'scatter',
                        data: myscore,
                        marker: {
                            fillColor: 'white',
                            lineWidth: 1,
                            lineColor: '#4FE0BE'
                        },
                        tooltip: {
                            pointFormat: '得分: {point.y}'
                        }
                    }]

                });
                var difficulty =[];
                for(var i = 0;i<result.linechart.difficulty.length;i++){
                    difficulty.push(parseInt(result.linechart.difficulty[i]));
                }
                //console.log(JSON.stringify(difficulty)+JSON.stringify(result.linechart.correctrate)+JSON.stringify(result.linechart.num)+JSON.stringify(result.linechart.qresult));

                var lineoption = {
                    tooltip : {
                        trigger: 'axis'
                    },
                    toolbox: {
                        show : false,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    color:[
                        '#779324', '#F7941D', '#7350C7', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD'
                    ],
                    //legend: {
                    //    show:true
                    //},
                    dataRange: {
                        show:false,
                        min: 99,
                        max: 100,
                        orient: 'horizontal',
                        y: 'top',
                        //text:['高','低'],           // 文本，默认为数值文本
                        color:['#779324','#E74C3C'],
                        splitNumber: 3
                    },
                    xAxis : [
                        {
                            type : 'category',
                            boundaryGap : false,
                            data : function (){
                                var list = [];
                                for (var i = 1; i <= result.linechart.num; i++) {
                                    list.push( i);
                                }
                                return list;
                            }()
                        },
                        {
                            type : 'value',
                            scale : true,
                            splitNumber: result.linechart.num-1,
                            axisLabel: {show:false},
                            splitLine: {show:false}
                        }
                    ],
                    yAxis : [
                        {
                            type : 'value',
                            max:1
                        },
                        {
                            type : 'value',
                            max:3
                        }
                    ],
                    animation: false,
                    series : [
                        {
                            name:'结果',
                            type:'scatter',
                            tooltip : {
                                trigger: 'item',
                                formatter : function (params) {
                                    //return  params.value[0] + '<br/>'
                                    //    + params.seriesName + ' : '
                                    //    + params.value[1] + ', '
                                    //    + params.value[2];
                                    var flag = params.value[2];
                                    if(flag == 99){
                                        return "错误！"
                                    }else{
                                        return "正确！"
                                    }
                                }
                            },
                            yAxisIndex:1,
                            xAxisIndex:1,
                            symbol: 'pin',
                            symbolSize: function (value){

                                var n = 8;
                                var flag = value[2];
                                if(flag == 99){
                                    n = 5;
                                }else{
                                    n = 8;

                                }
                                return n
                            },
                            data: result.linechart.qresult
                        },
                        {
                            name:'难度',
                            type:'line',
                            data:difficulty
                        },
                        {
                            name:'整体准确率',
                            type:'line',
                            data:function (){
                                var list = [];
                                for (var i = 0; i <= result.linechart.correctrate.length; i++) {
                                    list.push(parseFloat(result.linechart.correctrate[i]).toFixed(2));
                                }
                                return list;
                            }()
                            //data:result.linechart.correctrate
                        }
                    ]
                };
                var linechart = echarts.init(document.getElementById('main-linechart'));
                linechart.setOption(lineoption);
                window.onresize = linechart.resize;

                var timechartoption = {
                    tooltip : {
                        trigger: 'axis',
                        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                        }
                    },
                    color:[
                        '#51C3C9', '#538F7C', '#7350C7', '#32cd32', '#6495ed',
                        '#ff69b4', '#ba55d3', '#cd5c5c', '#ffa500', '#40e0d0',
                        '#1e90ff', '#ff6347', '#7b68ee', '#00fa9a', '#ffd700',
                        '#6b8e23', '#ff00ff', '#3cb371', '#b8860b', '#30e0e0'
                    ],
                    legend: {
                        data:['听力', '语法','阅读']
                    },
                    toolbox: {
                        show : false,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : true,
                    xAxis : [
                        {
                            type : 'value',
                            axisLabel : {
                                formatter: '{value} 秒'
                            }
                        }
                    ],
                    yAxis : [
                        {
                            type : 'category',
                            data : ['我的时间','最小时间','平均时间','最大时间']
                        }
                    ],
                    series : [
                        {
                            name:'听力',
                            type:'bar',
                            stack: '总量',
                            itemStyle : { normal: {barBorderRadius:[4, 4, 4, 4],label : {show: false, position: 'insideRight'}}},
                            //data:result.timechart.listening
                            data:function(){ var avg = result.timechart.listening;
                                var list = [];
                                for(var i= 0;i<avg.length;i++){
                                    if(i==2){
                                        list.push(parseFloat(avg[2]).toFixed(0)+"");
                                    }else{
                                        list.push(avg[i]+"");
                                    }
                                }
                                console.log("listening=="+list);
                                return list;
                            }()
                        },
                        {
                            name:'语法',
                            type:'bar',
                            stack: '总量',
                            itemStyle : { normal: {barBorderRadius:[4, 4, 4, 4],label : {show: false, position: 'insideRight'}}},
                            //data:result.timechart.grammar
                            data:function(){
                                var avg = result.timechart.grammar;
                                var list = [];
                                for(var i= 0;i<avg.length;i++){
                                    if(i==2){
                                        list.push(parseFloat(avg[2]).toFixed(0)+"");
                                    }else{
                                        list.push(avg[i]+"");
                                    }
                                }
                                console.log("grammar=="+list);
                                return list;
                            }()
                        },
                        {
                            name:'阅读',
                            type:'bar',
                            stack: '总量',
                            itemStyle : { normal: {barBorderRadius:[4, 4, 4, 4],label : {show: false, position: 'insideRight'}}},
                            //data:result.timechart.reading
                            data:function(){ var avg = result.timechart.reading;
                                var list = [];
                                for(var i= 0;i<avg.length;i++){
                                    if(i==2){
                                        list.push(parseFloat(avg[2]).toFixed(0)+"");
                                    }else{
                                        list.push(avg[i]+"");
                                    }
                                }
                                console.log("reading=="+list);
                                return list;
                            }()
                        }
                    ]
                };
                var timeChart = echarts.init(document.getElementById('main-timechart'));
                timeChart.setOption(timechartoption);
                window.onresize = timeChart.resize;

                var readingavg = [],readingmine = [],listeningavg = [],listeningmine = [],grammaravg = [],grammarmine = [];
                var  resultavg =  result.piegrammarchart.avg; var  resultmine =  result.piegrammarchart.mytime;
                //console.log(resultavg+"==="+resultmine);
                for(var i = 0;i<resultavg.length;i++){
                    //console.log(readingavg[i]);
                    if(i<15){
                        listeningavg.push(resultavg[i]);
                    }else if(i<40){
                        grammaravg.push(resultavg[i]);
                    }else{
                        readingavg.push(resultavg[i]);
                    }
                }
                for(var i = 0;i<resultmine.length;i++){
                    if(i<15){
                        listeningmine.push(resultmine[i]);
                    }else if(i<40){
                        grammarmine.push(resultmine[i]);
                    }else{
                        readingmine.push(resultmine[i]);
                    }
                }
                //console.log(listeningavg+"==="+listeningmine+grammaravg+readingmine);
                var piereadingoption = {
                    title: {
                        text: '阅读',
                        x: 'center',
                        y: 'center',
                        itemGap: 20,
                        textStyle : {
                            color : 'rgba(30,144,255,0.8)',
                            fontFamily : '微软雅黑',
                            fontSize : 15,
                            fontWeight : 'bolder'
                        }
                    },
                    tooltip : {
                        show:false,
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c}"
                    },
                    color:[
                        '#BE4BD4', '#A04EDE', '#7350C7', '#524EDE', '#4B6CD4',
                        '#BE4BD4', '#A04EDE', '#7350C7', '#524EDE', '#4B6CD4',
                        '#BE4BD4', '#A04EDE', '#7350C7', '#524EDE', '#4B6CD4',
                        '#BE4BD4', '#A04EDE', '#7350C7', '#524EDE', '#4B6CD4'
                    ],
                    legend: {
                        show:false,
                        orient : 'vertical',
                        x : 'left',
                        data:['1','2','3','4','5','6','7','8','9','10'],
                        selectedMode:false
                    },
                    toolbox: {
                        show : false,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {
                                show: true,
                                type: ['pie', 'funnel']
                            },
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : false,
                    series : [
                        {
                            name:'平均时长',
                            type:'pie',
                            selectedMode: 'single',
                            radius : [50, 58],
                            // for funnel
                            x: '20%',
                            width: '40%',
                            funnelAlign: 'right',
                            max: 1548,
                            itemStyle : dataStyle,
                            //data:result.piegrammarchart.avg
                            data:function(){ var avg = readingavg;
                                var list = [];
                                for(var i= 1;i<avg.length;i++){
                                    list.push({
                                        name: i,
                                        value:  Math.round(avg[i])
                                    });
                                }
                                list.push({
                                    name: 'invisible',
                                    value: 15,
                                    itemStyle : placeHolderStyle
                                });
                                return list;
                            }()
                        },

                        {
                            name:'我的考试时长',
                            type:'pie',
                            radius : [60, 80],

                            // for funnel
                            x: '60%',
                            width: '35%',
                            funnelAlign: 'left',
                            max: 1048,
                            data:function(){ var avg = readingmine;
                                var list = [];
                                for(var i= 1;i<avg.length;i++){
                                    list.push({
                                        name: i,
                                        value:  Math.round(avg[i])
                                    });
                                }
                                list.push({
                                    name: 'invisible',
                                    value: 15,
                                    itemStyle : placeHolderStyle
                                });
                                //alert(list);
                                return list;
                            }()
                        }
                    ]
                };
                var piereadingchart = echarts.init(document.getElementById('pie-reading'));
                // 为echarts对象加载数据
                piereadingchart.setOption(piereadingoption);
                window.onresize = piereadingchart.resize;

                var pielisteningoption = {
                    title: {
                        text: '听力',
                        x: 'center',
                        y: 'center',
                        itemGap: 20,
                        textStyle : {
                            color : 'rgba(30,144,255,0.8)',
                            fontFamily : '微软雅黑',
                            fontSize : 15,
                            fontWeight : 'bolder'
                        }
                    },
                    tooltip : {
                        show:false,
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c}"
                    },
                    color:[
                        '#4B86D6', '#4FB3E0', '#51C3C9', '#4FE0BE', '#4BD68F',
                        '#4B86D6', '#4FB3E0', '#51C3C9', '#4FE0BE', '#4BD68F',
                        '#4B86D6', '#4FB3E0', '#51C3C9', '#4FE0BE', '#4BD68F',
                        '#4B86D6', '#4FB3E0', '#51C3C9', '#4FE0BE', '#4BD68F'
                    ],
                    legend: {
                        show:false,
                        orient : 'vertical',
                        x : 'left',
                        data:['1','2','3','4','5','6','7','8','9','10'],
                        selectedMode:false
                    },
                    toolbox: {
                        show : false,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {
                                show: true,
                                type: ['pie', 'funnel']
                            },
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : false,
                    series : [
                        {
                            name:'平均时长',
                            type:'pie',
                            selectedMode: 'single',
                            radius : [50, 58],
                            // for funnel
                            x: '20%',
                            width: '40%',
                            funnelAlign: 'right',
                            max: 1548,
                            itemStyle : dataStyle,
                            //data:result.piegrammarchart.avg
                            data:function(){ var avg = listeningavg;
                                var list = [];
                                for(var i= 1;i<avg.length;i++){
                                    list.push({
                                        name: i,
                                        value:  Math.round(avg[i])
                                    });
                                }
                                list.push({
                                    name: 'invisible',
                                    value: 15,
                                    itemStyle : placeHolderStyle
                                });
                                //alert(list);
                                return list;
                            }()
                        },

                        {
                            name:'我的考试时长',
                            type:'pie',
                            radius : [60, 80],

                            // for funnel
                            x: '60%',
                            width: '35%',
                            funnelAlign: 'left',
                            max: 1048,
                            data:function(){ var avg = listeningmine;
                                var list = [];
                                for(var i= 1;i<avg.length;i++){
                                    list.push({
                                        name: i,
                                        value:  Math.round(avg[i])
                                    });
                                }
                                list.push({
                                    name: 'invisible',
                                    value: 15,
                                    itemStyle : placeHolderStyle
                                });
                                //alert(list);
                                return list;
                            }()
                        }
                    ]
                };
                var pielisteningchart = echarts.init(document.getElementById('pie-listening'));
                // 为echarts对象加载数据
                pielisteningchart.setOption(pielisteningoption);
                window.onresize = pielisteningchart.resize;

                var pieoption = {
                    title: {
                        text: '语法',
                        x: 'center',
                        y: 'center',
                        itemGap: 20,
                        textStyle : {
                            color : 'rgba(30,144,255,0.8)',
                            fontFamily : '微软雅黑',
                            fontSize : 15,
                            fontWeight : 'bolder'
                        }
                    },
                    tooltip : {
                        show:false,
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} "
                    },

                    color:[
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD'
                    ],
                    legend: {
                        show:false,
                        orient : 'vertical',
                        x : 'left',
                        data:['1','2','3','4','5','6','7','8','9','10'],
                        selectedMode:false
                    },
                    toolbox: {
                        show : false,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {
                                show: true,
                                type: ['pie', 'funnel']
                            },
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : false,
                    series : [
                        {
                            name:'平均时长',
                            type:'pie',
                            selectedMode: 'single',
                            radius : [50, 58],

                            // for funnel
                            x: '20%',
                            width: '40%',
                            funnelAlign: 'right',
                            max: 1548,
                            itemStyle : dataStyle,
                            //data:result.piegrammarchart.avg
                            data:function(){ var avg = grammaravg;
                                var list = [];
                                for(var i= 1;i<avg.length;i++){
                                    list.push({
                                        name: i,
                                        value:  Math.round(avg[i])
                                    });
                                }
                                list.push({
                                    name: 'invisible',
                                    value: 15,
                                    itemStyle : placeHolderStyle
                                });
                                //alert(list);
                                return list;
                            }()
                        },

                        {
                            name:'我的考试时长',
                            type:'pie',
                            radius : [60, 80],

                            // for funnel
                            x: '60%',
                            width: '35%',
                            funnelAlign: 'left',
                            max: 1048,
                            data:function(){ var avg =grammarmine;
                                var list = [];
                                for(var i= 1;i<avg.length;i++){
                                    list.push({
                                        name: i,
                                        value:  Math.round(avg[i])
                                    });
                                }
                                list.push({
                                    name: 'invisible',
                                    value: 15,
                                    itemStyle : placeHolderStyle
                                });
                                //alert(list);
                                return list;
                            }()
                        }
                    ]
                };
                var piegrammarchart = echarts.init(document.getElementById('pie-grammar'));
                // 为echarts对象加载数据
                piegrammarchart.setOption(pieoption);
                window.onresize = piegrammarchart.resize;
            }
        },
        error : function(errorMsg) {
            alert("不好意思，图表请求数据失败啦!");
        }
    });
}


function getPieChartsGrammarData() {
    //通过Ajax获取数据
    $.ajax({
        type : "post",
        //async : false, //同步执行
        url : "package.json",
        data : {},
        dataType : "json", //返回数据形式为json
        success : function(result) {
            if (result) {
                //alert(result.piegrammarchart.avg);
                var pieoption = {
                    title: {
                        text: '语法',
                        x: 'center',
                        y: 'center',
                        itemGap: 20,
                        textStyle : {
                            color : 'rgba(30,144,255,0.8)',
                            fontFamily : '微软雅黑',
                            fontSize : 15,
                            fontWeight : 'bolder'
                        }
                    },
                    tooltip : {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} "
                    },

                    color:[
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD'
                    ],
                    legend: {
                        show:false,
                        orient : 'vertical',
                        x : 'left',
                        data:['1','2','3','4','5','6','7','8','9','10'],
                        selectedMode:false
                    },
                    toolbox: {
                        show : false,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {
                                show: true,
                                type: ['pie', 'funnel']
                            },
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : false,
                    series : [
                        {
                            name:'平均时长',
                            type:'pie',
                            selectedMode: 'single',
                            radius : [50, 58],

                            // for funnel
                            x: '20%',
                            width: '40%',
                            funnelAlign: 'right',
                            max: 1548,
                            itemStyle : dataStyle,
                            //data:result.piegrammarchart.avg
                            data:function(){ var avg = result.piegrammarchart.avg;
                                var list = [];
                                for(var i= 1;i<avg.length;i++){
                                    list.push({
                                        name: i,
                                        value: avg[i]
                                    });
                                }
                                list.push({
                                    name: 'invisible',
                                    value: avg[0]/3,
                                    itemStyle : placeHolderStyle
                                });
                                //alert(list);
                                return list;
                            }()
                        },

                        {
                            name:'我的考试时长',
                            type:'pie',
                            radius : [60, 80],

                            // for funnel
                            x: '60%',
                            width: '35%',
                            funnelAlign: 'left',
                            max: 1048,
                            data:function(){ var avg = result.piegrammarchart.avg;
                                var list = [];
                                for(var i= 1;i<avg.length;i++){
                                    list.push({
                                        name: i,
                                        value: avg[i]
                                    });
                                }
                                list.push({
                                    name: 'invisible',
                                    value: avg[0]/3,
                                    itemStyle : placeHolderStyle
                                });
                                //alert(list);
                                return list;
                            }()
                        }
                    ]
                };
                var piegrammarchart = echarts.init(document.getElementById('pie-grammar'));
                // 为echarts对象加载数据
                piegrammarchart.setOption(pieoption);
                window.onresize = piegrammarchart.resize;

            }
        },
        error : function(errorMsg) {
            alert("不好意思，图表请求数据失败啦!");
        }
    });
}

function getPieChartsReadingData() {
    //通过Ajax获取数据
    $.ajax({
        type : "post",
        //async : false, //同步执行
        url : "package.json",
        data : {},
        dataType : "json", //返回数据形式为json
        success : function(result) {
            if (result) {
                //alert(result.piegrammarchart.avg);
                var pieoption = {
                    title: {
                        text: '阅读',
                        x: 'center',
                        y: 'center',
                        itemGap: 20,
                        textStyle : {
                            color : 'rgba(30,144,255,0.8)',
                            fontFamily : '微软雅黑',
                            fontSize : 15,
                            fontWeight : 'bolder'
                        }
                    },
                    tooltip : {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c}"
                    },
                    color:[
                        '#BE4BD4', '#A04EDE', '#7350C7', '#524EDE', '#4B6CD4',
                        '#BE4BD4', '#A04EDE', '#7350C7', '#524EDE', '#4B6CD4',
                        '#BE4BD4', '#A04EDE', '#7350C7', '#524EDE', '#4B6CD4',
                        '#BE4BD4', '#A04EDE', '#7350C7', '#524EDE', '#4B6CD4'
                    ],
                    legend: {
                        show:false,
                        orient : 'vertical',
                        x : 'left',
                        data:['1','2','3','4','5','6','7','8','9','10'],
                        selectedMode:false
                    },
                    toolbox: {
                        show : false,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {
                                show: true,
                                type: ['pie', 'funnel']
                            },
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : false,
                    series : [
                        {
                            name:'平均时长',
                            type:'pie',
                            selectedMode: 'single',
                            radius : [50, 58],
                            // for funnel
                            x: '20%',
                            width: '40%',
                            funnelAlign: 'right',
                            max: 1548,
                            itemStyle : dataStyle,
                            //data:result.piegrammarchart.avg
                            data:function(){ var avg = result.piegrammarchart.avg;
                                var list = [];
                                for(var i= 1;i<avg.length;i++){
                                    list.push({
                                        name: i,
                                        value: avg[i]
                                    });
                                }
                                list.push({
                                    name: 'invisible',
                                    value: 15,
                                    itemStyle : placeHolderStyle
                                });
                                return list;
                            }()
                        },

                        {
                            name:'我的考试时长',
                            type:'pie',
                            radius : [60, 80],

                            // for funnel
                            x: '60%',
                            width: '35%',
                            funnelAlign: 'left',
                            max: 1048,
                            data:function(){ var avg = result.piegrammarchart.avg;
                                var list = [];
                                for(var i= 1;i<avg.length;i++){
                                    list.push({
                                        name: i,
                                        value: avg[i]
                                    });
                                }
                                list.push({
                                    name: 'invisible',
                                    value: 15,
                                    itemStyle : placeHolderStyle
                                });
                                //alert(list);
                                return list;
                            }()
                        }
                    ]
                };
                var piereadingchart = echarts.init(document.getElementById('pie-reading'));
                // 为echarts对象加载数据
                piereadingchart.setOption(pieoption);
                window.onresize = piereadingchart.resize;

            }
        },
        error : function(errorMsg) {
            alert("不好意思，图表请求数据失败啦!");
        }
    });
}
function getPieChartsListeningData() {
    //通过Ajax获取数据
    $.ajax({
        type : "post",
        //async : false, //同步执行
        url : "package.json",
        data : {},
        dataType : "json", //返回数据形式为json
        success : function(result) {
            if (result) {
                //alert(result.piegrammarchart.avg);
                var pielisteningoption = {
                    title: {
                        text: '听力',
                        x: 'center',
                        y: 'center',
                        itemGap: 20,
                        textStyle : {
                            color : 'rgba(30,144,255,0.8)',
                            fontFamily : '微软雅黑',
                            fontSize : 15,
                            fontWeight : 'bolder'
                        }
                    },
                    tooltip : {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c}"
                    },
                    color:[
                        '#4B86D6', '#4FB3E0', '#51C3C9', '#4FE0BE', '#4BD68F',
                        '#4B86D6', '#4FB3E0', '#51C3C9', '#4FE0BE', '#4BD68F',
                        '#4B86D6', '#4FB3E0', '#51C3C9', '#4FE0BE', '#4BD68F',
                        '#4B86D6', '#4FB3E0', '#51C3C9', '#4FE0BE', '#4BD68F'
                    ],
                    legend: {
                        show:false,
                        orient : 'vertical',
                        x : 'left',
                        data:['1','2','3','4','5','6','7','8','9','10'],
                        selectedMode:false
                    },
                    toolbox: {
                        show : false,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType : {
                                show: true,
                                type: ['pie', 'funnel']
                            },
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : false,
                    series : [
                        {
                            name:'平均时长',
                            type:'pie',
                            selectedMode: 'single',
                            radius : [50, 58],
                            // for funnel
                            x: '20%',
                            width: '40%',
                            funnelAlign: 'right',
                            max: 1548,
                            itemStyle : dataStyle,
                            //data:result.piegrammarchart.avg
                            data:function(){ var avg = result.piegrammarchart.avg;
                                var list = [];
                                for(var i= 1;i<avg.length;i++){
                                    list.push({
                                        name: i,
                                        value:  Math.round(avg[i])
                                    });
                                }
                                list.push({
                                    name: 'invisible',
                                    value: 15,
                                    itemStyle : placeHolderStyle
                                });
                                //alert(list);
                                return list;
                            }()
                        },

                        {
                            name:'我的考试时长',
                            type:'pie',
                            radius : [60, 80],

                            // for funnel
                            x: '60%',
                            width: '35%',
                            funnelAlign: 'left',
                            max: 1048,
                            data:function(){ var avg = result.piegrammarchart.avg;
                                    var list = [];
                                    for(var i= 1;i<avg.length;i++){
                                        list.push({
                                            name: i,
                                            value: Math.round(avg[i])
                                        });
                                    }
                                    list.push({
                                        name: 'invisible',
                                        value: 15,
                                        itemStyle : placeHolderStyle
                                    });
                                    //alert(list);
                                return list;
                            }()
//                            data:[
//                                {value:35, name:'1'},
//                                {value:10, name:'2'},
//                                {value:34, name:'3'},
//                                {value:35, name:'4'},
//                                {value:10, name:'5'},
//                                {value:21, name:'6'},
//                                {value:17, name:'7'},
//                                {value:12, name:'8'},
//                                {
//                                    value:50,
//                                    name:'invisible',
//                                    itemStyle : placeHolderStyle
//                                }
//                            ]
                        }
                    ]
                };
                var pielisteningchart = echarts.init(document.getElementById('pie-listening'));
                // 为echarts对象加载数据
                pielisteningchart.setOption(pielisteningoption);
                window.onresize = pielisteningchart.resize;

            }
        },
        error : function(errorMsg) {
            alert("不好意思，图表请求数据失败啦!");
        }
    });
}
var dataStyle = {
    normal: {
        label: {show:false},
        labelLine: {show:false}
    }
};
var placeHolderStyle = {
    normal : {
        color: 'rgba(0,0,0,0)',
        label: {show:false},
        labelLine: {show:false}
    },
    emphasis : {
        color: 'rgba(0,0,0,0)',
        length:10
    }
};


function getPieChartsMatrixData(num) {
    //通过Ajax获取数据
    $.ajax({
        type : "post",
        //async : false, //同步执行
        url : "package.json",
        data : {
            num:num
        },
        dataType : "json", //返回数据形式为json
        success : function(result) {
            var subtext = '第'+num+'题';
            if (result) {
                //alert(result.piegrammarchart.avg);
                var matrixoption = {
                    title: {
                        text: '知识点',
                        subtext: subtext,
                        sublink: 'http://e.weibo.com/1341556070/AhQXtjbqh',
                        x: 'center',
                        y: 'center',
                        itemGap: 20,
                        textStyle : {
                            color : 'rgba(30,144,255,0.8)',
                            fontFamily : '微软雅黑',
                            fontSize : 15,
                            fontWeight : 'bolder'
                        }
                    },
                    color:[
                        '#51C3C9', '#538F7C', '#7350C7', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD'
                    ],
                    tooltip : {
                        show: false,
                        formatter: "{a} <br/>{b} : {c}"
                    },
                    legend: {
                        show:false,
                        orient : 'vertical',
                        //x : document.getElementById('matrix-1').offsetWidth / 2,
                        y : 45,
                        itemGap:12,
                        data:['听力','阅读','语法']
                    },
                    toolbox: {
                        show : false,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    series : [
                        {
                            name:'1',
                            type:'pie',
                            clockWise:false,
                            radius : [80, 90],
                            itemStyle : dataStyle,
                            data:[
                                {
                                    value:68,
                                    name:'听力'
                                },
                                {
                                    value:32,
                                    name:'invisible',
                                    itemStyle : placeHolderStyle
                                }
                            ]
                        },
                        {
                            name:'2',
                            type:'pie',
                            clockWise:false,
                            radius : [68, 78],
                            itemStyle : dataStyle,
                            data:[
                                {
                                    value:29,
                                    name:'阅读'
                                },
                                {
                                    value:71,
                                    name:'invisible',
                                    itemStyle : placeHolderStyle
                                }
                            ]
                        },
                        {
                            name:'3',
                            type:'pie',
                            clockWise:false,
                            radius : [56, 66],
                            itemStyle : dataStyle,
                            data:[
                                {
                                    value:3,
                                    name:'语法”'
                                },
                                {
                                    value:97,
                                    name:'invisible',
                                    itemStyle : placeHolderStyle
                                }
                            ]
                        }
                    ]
                };
                if(num==1){
                    matrixoption.color = [
                        '#51C3C9', '#538F7C', '#7350C7', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD'
                    ]
                }
                if(num==2){
                    matrixoption.color = [
                        '#80F9FF', '#84C4FF', '#A580FF', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD'
                    ]
                }
                if(num==3){
                    matrixoption.color = [
                        '#26787C', '#27527A', '#3E257A', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD'
                    ]
                }
                var id = 'matrix-'+num;
                //alert(id);
                var matrixchart = echarts.init(document.getElementById(id));
// 为echarts对象加载数据
                matrixchart.setOption(matrixoption);
                window.onresize = matrixchart.resize;
            }
        },
        error : function(errorMsg) {
            alert("不好意思，图表请求数据失败啦!");
        }
    });
}

function getPieChartsLineData() {
    //通过Ajax获取数据
    $.ajax({
        type : "post",
        //async : false, //同步执行
        url : "package.json",
        data : {},
        dataType : "json", //返回数据形式为json
        success : function(result) {
            if (result) {
                //alert(result.piegrammarchart.avg);
                var lineoption = {
                    tooltip : {
                        trigger: 'axis'
                    },
                    toolbox: {
                        show : false,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    color:[
                        '#779324', '#F7941D', '#7350C7', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                        '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD'
                    ],
                    //legend: {
                    //    selectedMode:false
                    //},
                    dataRange: {
                        show:false,
                        min: 99,
                        max: 100,
                        orient: 'horizontal',
                        y: 'top',
                        //text:['高','低'],           // 文本，默认为数值文本
                        color:['#779324','#E74C3C'],
                        splitNumber: 3
                    },
                    xAxis : [
                        {
                            type : 'category',
                            boundaryGap : false,
                            data : function (){
                                var list = [];
                                for (var i = 1; i <= result.linechart.num; i++) {
                                    list.push( i);
                                }
                                return list;
                            }()
                        },
                        {
                            type : 'value',
                            scale : true,
                            splitNumber: result.linechart.num-1,
                            axisLabel: {show:false},
                            splitLine: {show:false}
                        }
                    ],
                    yAxis : [
                        {
                            type : 'value'
                        },
                        {
                            type : 'value'
                        }
                    ],
                    animation: false,
                    series : [
                        {
                            name:'结果',
                            type:'scatter',
                            tooltip : {
                                trigger: 'item',
                                formatter : function (params) {
                                    //return  params.value[0] + '<br/>'
                                    //    + params.seriesName + ' : '
                                    //    + params.value[1] + ', '
                                    //    + params.value[2];
                                    var flag = params.value[2];
                                    if(flag == 99){
                                        return "错误！"
                                    }else{
                                        return "正确！"
                                    }
                                }
                            },
                            yAxisIndex:1,
                            xAxisIndex:1,
                            symbol: 'pin',
                            symbolSize: function (value){

                                var n = 8;
                                var flag = value[2];
                                if(flag == 99){
                                    n = 5;
                                }else{
                                    n = 8;

                                }
                                return n
                            },
                            data: result.linechart.result
                        },
                        {
                            name:'难度',
                            type:'line',
                            data:result.linechart.difficulty
                        },
                        {
                            name:'整体准确率',
                            type:'line',
                            data:result.linechart.correctrate
                        }
                    ]
                };
                var linechart = echarts.init(document.getElementById('main-linechart'));
// 为echarts对象加载数据
                linechart.setOption(lineoption);
                window.onresize = linechart.resize;
            }
        },
        error : function(errorMsg) {
            alert("不好意思，图表请求数据失败啦!");
        }
    });
}


function getliData(){
    $.ajax({
        type : "GET",
        //async : false, //同步执行
        url : "http://vip.classba.com/crm/index.php?m=evaluate&a=getAllAbility",
        data : {
            "rid":getCookie("rid"),
            "exam_id":1,
            "user_id":getCookie("uid")
        },
        dataType : "json", //返回数据形式为json
        success : function(result) {
            //console.log(JSON.stringify(result));
            if (result) {
                var num = result.length;
                var ketag = ["音形义","对话场景","句子理解","单词的拼写和形式","单词的义和形","单词的形，类和用","冠词（音形义类用）","人称代词（音形义类用）","介词的固定搭配（固定搭配）","关系疑问词的用法（音形义类用）", "句型","连词（音形义类用）","习惯用语","音形义类用","细节理解","判断词义","逻辑推理","主旨大意"];
                for(var i=0;i<num;i++){
                    var n = i+1;
                    var li = document.createElement('li');
                    li.setAttribute('id',"matrix-"+n);
                    $(".rp-matrix-list").append(li);
                    var str = ketag[result[i].key_tag];
                    if(str.length>6){
                        str=str.substring(0,5)+"\n"+ str.substring(6,str.length)
                    }
                    var matrixoption = {
                        title: {
                            text: str,
                            subtext: "",
                            sublink: "",
                            x: 'center',
                            y: 'center',
                            itemGap: 20,
                            textStyle : {
                                color : 'rgba(30,144,255,0.8)',
                                fontFamily : '微软雅黑',
                                fontSize : 10,
                                fontWeight : 'bolder',
                                wordWrap: "break-word",
                                padding:20
                            }
                        },
                        color:[
                            '#51C3C9', '#538F7C', '#7350C7', '#52BFDE', '#4ED4CD',
                            '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                            '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                            '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD'
                        ],
                        tooltip : {
                            show: true,
                            formatter: "{a} <br/>{b} : {c}"
                        },
                        legend: {
                            show:false,
                            orient : 'vertical',
                            //x : document.getElementById('matrix-1').offsetWidth / 2,
                            y : 45,
                            itemGap:12,
                            data:['最大能力值','平均能力值','我的能力值']
                        },
                        toolbox: {
                            show : false,
                            feature : {
                                mark : {show: true},
                                dataView : {show: true, readOnly: false},
                                restore : {show: true},
                                saveAsImage : {show: true}
                            }
                        },
                        series : [
                            {
                                name:'最大能力值',
                                type:'pie',
                                clockWise:false,
                                radius : [80, 90],
                                itemStyle : dataStyle,
                                data:[
                                    {
                                        value:result[i].all_max_ability,
                                        name:'最大能力值'
                                    },
                                    {
                                        value:32,
                                        name:'invisible',
                                        itemStyle : placeHolderStyle
                                    }
                                ]
                            },
                            {
                                name:'平均能力值',
                                type:'pie',
                                clockWise:false,
                                radius : [68, 78],
                                itemStyle : dataStyle,
                                data:[
                                    {
                                        value:result[i].all_avg_ability,
                                        name:'平均能力值'
                                    },
                                    {
                                        value:71,
                                        name:'invisible',
                                        itemStyle : placeHolderStyle
                                    }
                                ]
                            },
                            {
                                name:'我的能力值',
                                type:'pie',
                                clockWise:false,
                                radius : [56, 66],
                                itemStyle : dataStyle,
                                data:[
                                    {
                                        value:result[i].user_ability,
                                        name:'我的能力值”'
                                    },
                                    {
                                        value:97,
                                        name:'invisible',
                                        itemStyle : placeHolderStyle
                                    }
                                ]
                            }
                        ]
                    };
                    if(result[i].key_level==1){
                        matrixoption.color = [
                            '#51C3C9', '#538F7C', '#7350C7', '#52BFDE', '#4ED4CD',
                            '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                            '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                            '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD'
                        ]
                    }
                    if(result[i].key_level==2){
                        matrixoption.color = [
                            '#80F9FF', '#84C4FF', '#A580FF', '#52BFDE', '#4ED4CD',
                            '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                            '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                            '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD'
                        ]
                    }
                    if(result[i].key_level==3){
                        matrixoption.color = [
                            '#26787C', '#27527A', '#3E257A', '#52BFDE', '#4ED4CD',
                            '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                            '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                            '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD'
                        ]
                    }
                    var id = 'matrix-'+n;
                    var matrixchart = echarts.init(document.getElementById(id));
                    // 为echarts对象加载数据
                    matrixchart.setOption(matrixoption);
                    window.onresize = matrixchart.resize;
                }

            }
        },
        error : function(errorMsg) {
            alert("不好意思，图表请求数据失败啦!");
        }
    });
}
function getKeyData(){
    $.ajax({
        type : "GET",
        //async : false, //同步执行
        url : "http://vip.classba.com/crm/index.php?m=evaluate&a=getAllAbility",
        data : {
            "rid":getCookie("rid"),
            "exam_id":1,
            "user_id":getCookie("uid")
        },
        dataType : "json", //返回数据形式为json
        success : function(result) {
            //console.log(JSON.stringify(result));
            if (result) {
                var num = result.length;
                var keytag = ["音形义","对话场景","句子理解","单词的拼写和形式","单词的义和形","单词的形，类和用","冠词（音形义类用）","人称代词（音形义类用）","介词的固定搭配（固定搭配）","关系疑问词的用法（音形义类用）", "句型","连词（音形义类用）","习惯用语","音形义类用","细节理解","判断词义","逻辑推理","主旨大意"];
                var xAxis = [],myyAxis = [],avgyAxis = [], maxyAxis = [];
                for(var i=0;i<num;i++) {
                    xAxis.push(result[i].key_tag)
                    myyAxis.push(parseInt(result[i].user_ability)+5);
                    avgyAxis.push(parseInt(result[i].all_avg_ability)+5);
                    maxyAxis.push(parseInt(result[i].all_max_ability)+5);
                }
                option = {
                    tooltip : {
                        trigger: 'axis'
                    },
                    toolbox: {
                        show : false,
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            magicType: {show: true, type: ['line', 'bar']},
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    calculable : true,
                    legend: {
                        data:['我的能力值','最大能力值','平均能力值']
                    },
                    xAxis : [
                        {
                            type : 'category',
                            axisLabel: {
                                show:false,
                                rotate: 60,
                                //margin:-60,
                                textStyle:{
                                    color:'#076400'
                                }
                            },
                            data : keytag
                        }
                    ],
                    yAxis : [
                        {
                            type : 'value',
                            name : '我的能力值',
                            axisLabel : {
                                formatter: '{value} '
                            }
                        },
                        {
                            type : 'value',
                            name : '最大能力值',
                            axisLabel : {
                                formatter: '{value} '
                            }
                        },
                        {
                            type : 'value',
                            name : '平均能力值',
                            axisLabel : {
                                formatter: '{value} '
                            }
                        }
                    ],
                    series : [
                        {
                            name:'我的能力值',
                            type:'bar',
                            itemStyle: {
                                normal: {
                                    color: function(params) {
                                        // build a color map as your need.
                                        var colorList = [
                                            //'#80F9FF', '#84C4FF', '#A580FF', '#52BFDE', '#4ED4CD',
                                            //'#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                                            //'#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                                            //'#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD'
                                            '#C1232B','#B5C334','#FCCE10','#E87C25','#27727B',
                                            '#FE8463','#9BCA63','#FAD860','#F3A43B','#60C0DD',
                                            '#D7504B','#C6E579','#F4E001','#F0805A','#26C0C0',
                                            '#80F9FF', '#84C4FF', '#A580FF', '#52BFDE', '#4ED4CD',
                                            '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                                            '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD',
                                            '#4F4ED4', '#5275DE', '#538F7C', '#52BFDE', '#4ED4CD'
                                        ];
                                        return colorList[params.dataIndex]
                                    },
                                    label: {
                                        show: false,
                                        position: 'top',
                                        formatter: '{b}\n{c}'
                                    },
                                    barBorderRadius:[4, 4, 4, 4]
                                }
                            },

                            data:myyAxis
                        },
                        {
                            name:'最大能力值',
                            type:'line',
                            //yAxisIndex: 1,
                            data:maxyAxis
                        },
                        {
                            name:'平均能力值',
                            type:'line',
                            //yAxisIndex: 1,
                            data:avgyAxis
                        }
                    ]
                };
                var matrixchart = echarts.init(document.getElementById("matrixchart"));
                // 为echarts对象加载数据
                matrixchart.setOption(option);
                window.onresize = matrixchart.resize;
            }
        },
        error : function(errorMsg) {
            alert("不好意思，图表请求数据失败啦!");
        }
    });
}